Designing Mobile Robot Interfaces with 16-bit Microchip Microcontrollers by Ahmet Bindal

Designing Mobile Robot Interfaces with 16-bit Microchip Microcontrollers by Ahmet Bindal

Author:Ahmet Bindal
Language: eng
Format: epub
ISBN: 9783031278419
Publisher: Springer International Publishing


Fig. 5.49 describes the ISR, DAC1RInterrupt, and the application program that uses this ISR.

Fig. 5.49 Interrupt Service Routine setup and DAC1 operation

Initially, the index, i, is set to zero while the DAC1 unit is initialized and enabled. Since only the right channel of DAC1 is used, the interrupt flag for this channel, IFS4bits.DAC1RIF, is first cleared, and then enabled by the statement, IEC4bits.DAC1RIE = 1. When the right channel data buffer, DAC1RDAT, becomes full of data the interrupt triggers, and IFS4bits.DAC1RIF = 1. The program subsequently clears the interrupt by IFS4bits.DAC1RIF = 0, and goes to the if (i == 0) statement to assign i = 1, and DAC1RDAT = 0xFFFF. When the DAC1RIF fires the second time, the program goes into the else-statement, and assigns i = 1, and DAC1RDAT = 0x1111 since the interrupt is still enabled. The ping-pong motion of the analog signal, corresponding to 0xFFFF and 0x1111 values, can be seen from the DAC1RP terminal (RB12 pin) on the oscilloscope.

Projects

1.

Write a program for the ADC unit in dspic33fj128mc802 such that an analog signal at AN0 is sampled continuously in auto sampling mode as shown in Program 5.2. First, apply a series of constant analog voltages at AN0 and check each 16-bit digital value generated by the ADC in the Watch window by inserting breakpoints in the program. Once this step is successfully accomplished, then apply an analog waveform, such as sinusoidal or a triangular signal, at AN0. Store the digital data in the data memory. Compare what is stored against the expected values.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.